<template>
	<view class="adoptDetails">
		<view class="orderItem">
			<view class="order_info_top_box">
				<view class="order_sn">
					<span class="mar-right-10">订单编号</span>
					<span>{{details.order_sn}}</span>
				</view>
				<view class="order_status">
					<span>剩余:{{details.remain_day}}天</span>
				</view>
			</view>
			<view class="order_info_center_box">
				<view class="order_goods_img">
					<image :src="details.cover" mode=""></image>
				</view>
				<view class="order_info_details">
					<view class="order_goods_item_name more-text2">{{details.order_name}}</view>
					<view class="order_goods_num">
						<view class="fn-sz-28 fn-cl-666666 mar-right-54">{{details.farm_product_option_name}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="area-title">
			商家信息
		</view>
		<view class="store_info_box">
			<view class="ground_store_image">
				<image :src="details.image" mode=""></image>
			</view>
			<view class="ground_store_info">
				<view class="ground_store_name">
					{{details.name}}
				</view>
				<view class="ground_store_address">
					{{details.province}}
					{{details.city}}
					{{details.county}}
					{{details.address}}
				</view>
			</view>
		</view>
		<view class="area-title">
			收货信息
		</view>
		<view class="order_address">
			<view class="address_left_box">
				<view class="address_icon">
					<image src="../../static/images/icon/icon_gps1.png" mode=""></image>
				</view>
				<view class="address_info_box">
					<view class="address_name">
						{{details.farm_address.province}}
						{{details.farm_address.city}}
						{{details.farm_address.county}}
						{{details.farm_address.address}}
						<span v-if="details.farm_address.num"> {{details.farm_address.num}}</span>
					</view>
					<view class="address_info_desc">
						{{details.farm_address.fullname}}
						{{details.farm_address.phone}}
					</view>
				</view>
			</view>
			<view class="address_right_btn">
				<image src="../../static/images/icon/icon_moer_btn.png" mode=""></image>
			</view>
		</view>
		<view class="area-title">
			认养信息
		</view>
		<view class="order_desc_list">
			<view class="order_decs_line_box">
				<view class="order_decs_title_box">
					土地类型
				</view>
				<view class="order_decs_content_box">
					{{details.area}}㎡{{details.farm_product_option_name}}
				</view>
			</view>
			<view class="order_decs_line_box">
				<view class="order_decs_title_box">
					租赁时长
				</view>
				<view class="order_decs_content_box">
					一年（365天）
				</view>
			</view>
			<view class="order_decs_line_box">
				<view class="order_decs_title_box">
					服务类型
				</view>
				<view class="order_decs_content_box">
					<span
						v-if="details.day_type=='year'&&details.service_type!='own'">{{serviceType[details.service_type]}}（￥{{details.service_single_price}}/天）</span>
					<span
						v-if="details.day_type=='half_year'&&details.service_type!='own'">{{serviceType[details.service_type]}}（（￥{{details.service_single_price}}/天）</span>
					<span v-if="details.service_type=='own'">{{serviceType[details.service_type]}}</span>
				</view>
			</view>
			<view class="order_decs_line_box">
				<view class="order_decs_title_box">
					认养金额
				</view>
				<view class="order_decs_content_box">
					￥{{details.order_price}}
				</view>
			</view>
			<view class="order_decs_line_box">
				<view class="order_decs_title_box">
					金币抵扣
				</view>
				<view class="order_decs_content_box">
					￥{{details.coin_price}}
				</view>
			</view>
		</view>
		<view class="bottom_op_box">
			<button class="add_car_btn" @tap="addSeed">新增种子</button>
			<button class="buy_now" @tap="checkGet">查看收获</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				details: {},
				serviceType: {
					own: '自行种植',
					all: '全包',
					half: '半包'
				},
			};
		},
		onLoad(val) {
			if (val.id) {
				this.$api.getAdoptOrderDetail({
					order_id: val.id
				}).then(res => {
					this.details = res.data
				})
			}
		},
		methods: {
			addSeed() {
				let area = this.details.area - this.details.doing_area;
				if (this.details.seed.length) {
					uni.navigateTo({
						url: `/pages/adoptRecords/addSeed?id=${this.details.farm_product_id}&order_id=${this.details.id}&area=${area}`
					})
				} else {
					this.$helper.toast('没有剩余种植面积');
				}
			},
			checkGet() {
				uni.navigateTo({
					url: `/pages/adoptRecords/reapRecord?order_id=${this.details.id}`
				})
			}
		}
	}
</script>

<style lang="scss">
	.adoptDetails {
		padding: 20rpx 24rpx 220rpx;
		min-height: 100vh;
		background-color: #f9f9f9;

		.orderItem {
			background: #ffffff;
			border-radius: 20rpx;
			padding: 32rpx 24rpx;
			margin-bottom: 20rpx;

			.order_info_top_box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-bottom: 28rpx;
				border-bottom: 1rpx dashed #cccccc;

				.order_sn {
					font-size: 28rpx;
					font-weight: 400;
					color: #666666;
				}

				.order_status {
					font-size: 30rpx;
					font-weight: 500;
					color: #222222;
				}
			}

			.order_info_center_box {
				display: flex;
				padding: 29rpx 0 0;

				.order_goods_img {
					flex: none;
					margin-right: 23rpx;

					image {
						width: 150rpx;
						height: 150rpx;
						border-radius: 10rpx;
					}
				}

				.order_info_details {
					flex: 1;

					.order_goods_item_name {
						font-size: 28rpx;
						font-weight: 400;
						color: #222222;
						margin-bottom: 55rpx;
					}

					.order_goods_num {}
				}
			}
		}

		.store_info_box {
			display: flex;
			margin-bottom: 30rpx;
			background-color: #ffffff;
			border-radius: 20rpx;
			padding: 20rpx 22rpx;

			.ground_store_image {
				width: 90rpx;
				height: 90rpx;
				border-radius: 10rpx;
				overflow: hidden;
				flex: none;
				margin-right: 15rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.ground_store_info {
				.ground_store_name {
					font-size: 30rpx;
					color: #222222;
					margin-bottom: 11rpx;
				}

				.ground_store_address {
					font-size: 24rpx;
					color: #999999;
				}
			}
		}

		.order_address {
			background: #ffffff;
			border-radius: 20rpx;
			padding: 33rpx 15rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 30rpx;

			.address_left_box {
				display: flex;
				align-items: center;

				.address_icon {
					width: 32rpx;
					height: 39rpx;
					margin-right: 20rpx;
					flex: none;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.address_info_box {
					.address_name {
						font-weight: 500;
						font-size: 34rpx;
						color: #333333;
						margin-bottom: 6rpx;
					}

					.address_info_desc {
						font-size: 28rpx;
						color: #999999;
					}
				}
			}

			.address_right_btn {
				width: 38rpx;
				height: 38rpx;
				flex: none;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.order_desc_list {
			background: #ffffff;
			border-radius: 20rpx;
			padding: 28rpx 23rpx;

			.order_decs_line_box {
				display: flex;
				margin-bottom: 37rpx;

				.order_decs_title_box {
					font-weight: 400;
					font-size: 28rpx;
					color: #999999;
					margin-right: 20rpx;
				}

				.order_decs_content_box {
					font-size: 28rpx;
					color: #333333;
				}
			}
		}

		.bottom_op_box {
			display: flex;
			position: relative;
			width: 100vw;
			align-items: center;
			background: #ffffff;
			justify-content: space-between;
			padding: 19rpx 23rpx;
			position: fixed;
			box-sizing: border-box;
			bottom: 0;
			left: 0;

			.add_car_btn {
				width: 48%;
				height: 80rpx;
				background: #ffffff;
				border-radius: 40rpx;
				border: 2rpx solid #cccccc;
				color: #333333;
				font-size: 30rpx;
			}

			.buy_now {
				width: 48%;
				height: 80rpx;
				background: #fed100;
				border-radius: 40rpx;
				font-size: 30rpx;
			}
		}
	}
</style>